
using Mbs.ComponentModel.Container;
namespace Mbs.Elements
{
    [Component(Id = "ElementService", Service = typeof(IElementService))]
    public class ElementService : MarshalAndDisposableObject, IElementService
    {
        public IElementFactoryRepository Factories { get; private set; }
        public IElementCommandRepository Commands { get; private set; }
        public IElementCategoryRepository Sites { get; private set; }
        public IElementMapRepository ElementMap { get; private set; }

        public ElementService()
        {
            Factories = new ElementFactoryRepository();
            Commands = new ElementCommandRepository(this);
            Sites = new ElementCategoryRepository();
            ElementMap = new ElementMapRepository(Factories);
            Factories.RegisterFactory(new SimpleElementFactory());
        }

        protected override void Dispose(bool disposing)
        {
            Factories.Clear();
            ElementMap.Clear();
            Commands.Dispose();
            Sites.Dispose();
        }
    }
}
